package com.zsh.spring.service;

import com.zsh.spring.dao.BookDao;
import com.zsh.spring.entity.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {
//    注入DAO

    @Autowired
    private BookDao bookDao;

    public void addBook(Book book){
        bookDao.add(book);
    }

    public void updateBook(Book book){
        bookDao.updateBook(book);
    }

    public void deleteBook(Integer id){
        bookDao.deleteBook(id);
    }

    public int queryCount(){
        return  bookDao.selectCount();
    }

    public Book queryOneBook(Integer id){
        return bookDao.queryOneBookById(id);
    }

    public List<Book> queryAllBooks(){
        return bookDao.queryAllBooks();
    }

    public void batchAdd(List<Object[]> batchArgs ){
        bookDao.batchAddBook(batchArgs);
    }
}
